// 对称加密：根据秘钥可以加密一个明文字符串，然后根据秘钥也可以解密这个加密的字符串
const jwt = require('jsonwebtoken');

const user = {
    uid: 2,
    mobile: '13811065680',
};

const key = '123456';

const encode = jwt.sign(user, key, { expiresIn: '2h' });

console.log('encode', encode);

const decode = jwt.verify(
    'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEsIm1vYmlsZSI6IjEzODExMDY1NjgwIiwiaWF0IjoxNTkzMjE5MzEzLCJleHAiOjE1OTMyMjY1MTN9.Tyrxnv1z7j5HQtTPakRcx6ZQoJC19qUB2wO490FOeCE',
    key,
);

console.log('decode', decode);
